package org.rsbot.loader.asm;

public class Attribute
{
  public final String type;
  byte[] value;
  Attribute next;

  protected Attribute(String paramString)
  {
    this.type = paramString;
  }

  public boolean isUnknown()
  {
    return true;
  }

  public boolean isCodeAttribute()
  {
    return false;
  }

  protected Label[] getLabels()
  {
    return null;
  }

  protected Attribute read(ClassReader paramClassReader, int paramInt1, int paramInt2, char[] paramArrayOfChar, int paramInt3, Label[] paramArrayOfLabel)
  {
    Attribute localAttribute = new Attribute(this.type);
    localAttribute.value = new byte[paramInt2];
    System.arraycopy(paramClassReader.b, paramInt1, localAttribute.value, 0, paramInt2);
    return localAttribute;
  }

  protected ByteVector write(ClassWriter paramClassWriter, byte[] paramArrayOfByte, int paramInt1, int paramInt2, int paramInt3)
  {
    ByteVector localByteVector = new ByteVector();
    localByteVector.data = this.value;
    localByteVector.length = this.value.length;
    return localByteVector;
  }

  final int getCount()
  {
    int i = 0;
    Attribute localAttribute = this;
    while (localAttribute != null) {
      i++;
      localAttribute = localAttribute.next;
    }
    return i;
  }

  final int getSize(ClassWriter paramClassWriter, byte[] paramArrayOfByte, int paramInt1, int paramInt2, int paramInt3)
  {
    Attribute localAttribute = this;
    int i = 0;
    while (localAttribute != null) {
      paramClassWriter.newUTF8(localAttribute.type);
      i += localAttribute.write(paramClassWriter, paramArrayOfByte, paramInt1, paramInt2, paramInt3).length + 6;
      localAttribute = localAttribute.next;
    }
    return i;
  }

  final void put(ClassWriter paramClassWriter, byte[] paramArrayOfByte, int paramInt1, int paramInt2, int paramInt3, ByteVector paramByteVector)
  {
    Attribute localAttribute = this;
    while (localAttribute != null) {
      ByteVector localByteVector = localAttribute.write(paramClassWriter, paramArrayOfByte, paramInt1, paramInt2, paramInt3);
      paramByteVector.putShort(paramClassWriter.newUTF8(localAttribute.type)).putInt(localByteVector.length);
      paramByteVector.putByteArray(localByteVector.data, 0, localByteVector.length);
      localAttribute = localAttribute.next;
    }
  }
}